// 定义设备类型枚举
enum BemfaDeviceType
{
    BF_TYPE_COMMON,          // 普通设备
    BF_TYPE_SOCKET,          // 插座设备
    BF_TYPE_BULB,            // 灯泡设备
    BF_TYPE_FAN,             // 风扇设备
    BF_TYPE_SENSOR,          // 传感器设备
    BF_TYPE_AIR_CONDITIONER, // 空调设备
    BF_TYPE_SWITCH,          // 开关设备
    BF_TYPE_CURTAIN,         // 窗帘设备
};
BemfaDeviceType getDeviceTypeForTopic(const char *topic)
{
    // 确保主题字符串至少有3个字符用于比较
    size_t topicLength = strlen(topic);
    if (topicLength < 3)
    {
        return BF_TYPE_COMMON;
    }

    // 取出主题字符串的后三位
    const char *lastThreeChars = topic + topicLength - 3;

    if (strcmp(lastThreeChars, "001") == 0)
        return BF_TYPE_SOCKET;
    else if (strcmp(lastThreeChars, "002") == 0)
        return BF_TYPE_BULB;
    else if (strcmp(lastThreeChars, "003") == 0)
        return BF_TYPE_FAN;
    else if (strcmp(lastThreeChars, "004") == 0)
        return BF_TYPE_SENSOR;
    else if (strcmp(lastThreeChars, "005") == 0)
        return BF_TYPE_AIR_CONDITIONER;
    else if (strcmp(lastThreeChars, "006") == 0)
        return BF_TYPE_SWITCH;
    else if (strcmp(lastThreeChars, "009") == 0)
        return BF_TYPE_CURTAIN;
    else
        return BF_TYPE_COMMON;
}